package org.mashibing.controller;

import org.mashibing.dto.PassengerUser;
import org.mashibing.dto.ResponseResult;
import org.mashibing.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author:
 * @create: 2024/4/1 17:05
 * @description: 乘客用户相关
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据accessToken获取用户基本信息
     */
    @GetMapping("/users")
    public ResponseResult<PassengerUser> getUser(HttpServletRequest httpRequest) {
        String accessToken = httpRequest.getHeader("Authorization");
        return userService.getUserByPhone(accessToken);
    }
}
